<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="white" />
    <title>云矿</title>
    <link rel="stylesheet" href="../public/css/weui.css" />
	<link rel="stylesheet" href="../public/css/jquery-weui.css">
    <link rel="stylesheet" href="../public/css/common.css" />
    <link rel="stylesheet" href="css/index.css" />
	<style>
		[v-cloak]{
			display: none;
		}
	</style>
</head>
<body style="background: #FFFFFF;">
<div id="digindex" v-cloak>
	<div class="digindex-header">
		<div class="weui-cell showlogo">
			<div class="weui-cell__hd">
				<img src="../public/images/yunkuanglogo.png" />
			</div>
			<div class="weui-cell__bd">云矿</div>
			<div class="weui-cell__ft more" id="more">
				<img src="../public/images/more.png">
			</div>
		</div>
		<div class="digindex-header-title">
			<span>我的资产</span>
			<img :src="isVisibleImg" @click="isvisible(changeImg)"/>
		</div>
		<div v-if="ishide" class="digindex-header-amount">{{coin+integral}}</div>
		<div v-else class="digindex-header-amount">****</div>
		<div class="digindex-header-msg">账户总额(元)</div>
	</div>
	<div class="digindex-amount-content" v-cloak>
		<div class="weui-navbar">
			<div class="weui-navbar__item">
				<div v-if="ishide" class="content">{{coin}}</div>
				<div v-else class="content">****</div>
				<div class="title">云币</div>
			</div>
			<div class="weui-navbar__item">
				<div v-if="ishide" class="content">{{integral}}</div>
				<div v-else class="content">****</div>
				<div class="title">云积分</div>
			</div>
		</div>
	</div>
	<div v-if="mymilllist.length>0" v-cloak>
		<div class="digindex-mill-title">我的矿机</div>
		<div class="digindex-mymill-list">
			<div class="item" v-for="(item,index) in mymilllist">
				<div class="digindex-mymill-number weui-cell">
					<div class="weui-cell__bd">{{item.name}}</div>
					<div class="weui-cell__ft">{{item.mill.name}}</div>
				</div>
				<img class="mill-img" :src="'..'+item.mill.millPhoto" @click="jump(item.id)"/>
				<div class="weui-cell digindex-mymill-earnings">
					<div class="weui-cell__hd">累计收益:{{item.allincome}}</div>
					<div class="weui-cell__bd">昨日收益：{{item.yesterdayincome}}</div>
					<div class="weui-cell__ft" @click="harvesters(item.id)">收矿</div>
				</div>
				<div class="weui-cell digindex-mill-parameter" v-cloak>
					<div class="weui-cell__hd">算力天数:<span>{{parseInt(item.hourNum/24)}}</span>天</div>
					<div class="weui-cell__bd">收益:<span>{{item.mill.rate*100}}%</span></div>
					<div class="weui-cell__ft">每日算力:<span>{{item.mill.arithmeticStrength}}%</span></div>
				</div>
			</div>
		</div>
	</div>
	<div v-else v-cloak>
		<div class="digindex-mill-title">购买矿机</div>
		<div class="digindex-mill-list">
			<div class="item" v-for="item in milllist">
				<img class="mill-img" :src="'..'+item.millPhoto" />
				<div class="weui-cell digindex-mill-earnings">
					<div class="weui-cell__hd">{{item.name}}</div>
					<div class="weui-cell__bd">{{item.limitStart}}~{{item.limitEnd}}云币</div>
					<div class="weui-cell__ft" @click="jumpTo(item.name,item.id)">购买</div>
				</div>
				<div class="weui-cell digindex-mill-parameter">
					<div class="weui-cell__hd">算力天数:<span>{{item.daysNum}}</span>天</div>
					<div class="weui-cell__bd">收益:<span>{{item.rate*100}}%</span></div>
					<div class="weui-cell__ft">每日算力:<span>{{item.arithmeticStrength}}</span></div>
				</div>
			</div>
		</div>
	</div>
	<div style="height: 1.4rem;"></div>
	<div class="common-bottom">
		<ul>
			<li class="active">
				<a href="index.html">
					<div class="icon icon-1"></div>
					<div class="text">首页</div>
				</a>
			</li>
			<li>
				<a href="buymill.html">
					<div class="icon icon-2"></div>
					<div class="text">矿机</div>
				</a>
			</li>
			<li>
				<a href="../wallet/index.html">
					<div class="icon icon-3"></div>
					<div class="text">钱包</div>
				</a>
			</li>
			<li>
				<a href="../personal/index.html">
					<div class="icon icon-4"></div>
					<div class="text">我的</div>
				</a>
			</li>
		</ul>
	</div>
	<!-- 弹窗广告 -->
	<div :class="{'showajax':showadvert,'hideajax':!showadvert}">
		<div class="weui-mask weui-mask--visible" @click="hideadvert"></div>
		<div class="workforce">
			<div class="content">
				<div class="showcontent" @click="todetail">
					<div class="title">点击查看活动详情</div>
				</div>
				<img class="canceladvert" src="../public/images/shutdown.png" @click="hideadvert" />
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="../public/js/jquery-2.1.4.js"></script>
<script type="text/javascript" src="../public/js/jquery-weui.js"></script>
<script type="text/javascript" src="../public/js/vue.js" ></script>
<script type="text/javascript" src="../public/js/font_size.js" ></script>
<script type="text/javascript" src="../public/js/common.js" ></script>
<script type="text/javascript">
    $(function(){
        var vm = new Vue({
            el:"#digindex",
            data: {
            	showadvert:true,
				isVisibleImg:"../public/images/zcks.png",
				changeImg:0,
				ishide:true,
				coin:0,
				integral:0,
            	mymilllist:[],
            	milllist:[]
            },
            methods:{
                hideadvert:function(){
					this.showadvert = false;
					sessionStorage.showadvert=false;
				},
				todetail:function(){
					window.location.href = 'activitydetail.html';
				},
				isvisible:function(id){
					if(id==0){
					    this.isVisibleImg="../public/images/isvisible.png";
					    this.ishide=false;
					    this.changeImg=1;
					}else{
					    this.isVisibleImg="../public/images/zcks.png";
					    this.ishide=true;
					    this.changeImg=0;
					}
				},
				jumpTo:function(name,id){
				    local.saveData("milldetail",{
				        millname:name,
						millid:id
					})
				    window.location.href="./createmill.html";
				},
				jump:function(id){
                    location.href='./millshow.html?millid='+id;
				},
                harvesters:function(millid){
                    AjaxRequest({
                        url:_url+"/money/mill/findOutputMoney",
                        data:{
                            millid:millid
                        },
                        type:"post",
                        success:(res)=>{
                            var canusegolb = res.data;
                            if(canusegolb.length>0)
                                AjaxRequest({
                                    url:_url+"/money/mill/onekeyMill",
                                    data:{
                                        userid:local.getData("yb_user_info").id,
                                        myMillid :millid
                                    },
                                    type:"post",
                                    success(res){
                                        if(res.code==1){
                                            AjaxRequest({
                                                url:_url+"/money/mill/mymill",
                                                data:{
                                                    userid:local.getData("yb_user_info").id,
                                                },
                                                type:"post",
                                                success(res){
                                                    var mills=res.data.mymills;
                                                    for(var i=0;i<mills.length;i++){
                                                        if(mills[i].mill.$ref){
                                                            var a = mills[i].mill.$ref.split("[")[1];
                                                            var b = a.split("]")[0];
                                                            mills[i].mill=mills[b].mill;
                                                        }
                                                    }
                                                    vm.mymilllist=mills;
                                                }
                                            })
                                        }
                                    }
                                });
                            else
                            {
                                $.alert("暂时没有挖出新币，等会儿再来吧！");
                            }
                        }
                    });
                }
            },
			created:function(){
                var id=local.getData("yb_user_info").id;
                AjaxRequest({
                    url:_url+"/money/mill/mymill",
                    type:"post",
					load:true,
                    data:{
                        userid:id
                    },
                    success(res){
                        if(res.code==1){
                            var mills=res.data.mymills;
                            for(var i=0;i<mills.length;i++){
                                if(mills[i].mill.$ref){
                                    var a = mills[i].mill.$ref.split("[")[1];
                                    var b = a.split("]")[0];
                                    mills[i].mill=mills[b].mill;
								}
							}
                            vm.mymilllist=mills;
						}
                        if(vm.mymilllist<1){
                            AjaxRequest({
                                url:_url+"/money/mill/millall",
                                load:true,
                                type:"post",
                                success(res){
                                    if(isReqSucceed(res))
                                        vm.milllist=res.data;
                                }
                            })
						}
                    }
                });
                AjaxRequest({
                    url:_url+"/money/wallet/mywallet",
                    data:{userid:id},
                    load:true,
                    type:"post",
                    success(res){
                        if(isReqSucceed(res)){
                            vm.coin=res.data.yunB;
                            vm.integral=res.data.yunScore;
                        }
                    }
                });
                if(sessionStorage.showadvert=="false"){
                    this.showadvert=false;
				}
			}
        })
        $("#more").click(function () {
                $.actions({
                    actions:[{
                        text:"扫一扫",
                        onClick:function() {
                            $(window).attr("location","../wallet/trans-accounts.html?type=0");
                        }
                    },{
                        text:"分享推广",
                        onClick:function () {
                            $(window).attr("location","../personal/share.html");
                        }
                    },{
                        text:"关于云矿",
                        onClick:function () {
                            $(window).attr("location","../personal/about-us.html");
					}
                    }]
                })
            }
        )
    })
</script>
</body>
</html>



